<!--
 * @Author: yuanming
 * @Date: 2024-08-30 15:40:38
 * @LastEditors: yuanming
 * @LastEditTime: 2024-08-30 15:54:10
 * @Description: fileDescription
-->
<template>
    <div class="login_container">
        <div class="login_box">
            <img src="@/assets/images/login.gif" alt="" srcset="" class="loginImg">
            <div class="textClass">已打开密码保护，请输入密码</div>
            <el-input v-model="password" show-password size="large" placeholder="请输入密码">
                <template #append>
                    <el-button type="primary" @click="submit">确定</el-button>
                </template>
            </el-input>
        </div>
    </div>
</template>
<script setup>
import md5 from 'md5'

import router from '@/router/index.js'

const password = ref('')

const { proxy } = getCurrentInstance()

const submit = () => {
    const timestamp = new Date().getTime()
    const params = {
        password: md5(md5(password.value) + timestamp),
        timestamp, // 当前时间戳
    }
    proxy.$api.checkPassword(params).then((res) => {
        if (res) {
            sessionStorage.setItem('token', res)
            router.push('/')
        }
    })
}
</script>
<style lang="scss" scoped>
.login_container {
    width: 100vw;
    height: 100vh;
    background-color: #0f2a41;
    display: flex;
    justify-content: center;
    align-items: center;
    .login_box {
        width: 18vw;
        height: auto;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        .textClass {
            color: white;
            margin: 2vh 0 3vh 0;
        }
        .loginImg {
            width: 10vw;
            height: 20vh;
        }
    }
}
</style>